package ModelLayer;
import java.util.*;

/**
 * Write a description of class Copy here.
 * 
 * @author (Group1:Georgi,Roland and Mindaugas) 
 * @version (a version number or a date)
 */
public class Copy
{
    private long serialNumber;
    private String purchaseDate;
    private int purchasePrice;
    private ArrayList<Loan> loans;
   
    /**
     * Constructor of Class Copy.
     */
    public Copy(long serialNumber, String purchaseDate, int purchasePrice)
    {
       this.serialNumber=serialNumber;
       this.purchaseDate=purchaseDate;
       this.purchasePrice=purchasePrice;
       
       loans = new ArrayList<Loan>();
    }
    // Accesor Methods
    public long getSerialNumber()
    {
        return serialNumber;
    }
    
    public String getPurchaseDate()
    {
        return purchaseDate;
    }
    
    public int getPurchasePrice()
    {
        return purchasePrice;
    }
    
    // Mutator Methods
    public void setSerialNumber(long serialNumber)
    {
        this.serialNumber=serialNumber;
    }
    
    public void setPurchaseDate(String purchaseDate)
    {
        this.purchaseDate=purchaseDate;
    }
    
    public void setPurchasePrice(int purchasePrice)
    {
        this.purchasePrice=purchasePrice;
    }
    
    /**
     * Lists all the serial numbers of existing Copies.
     */
    public ArrayList<Long> getSerialNumbers()
    {
        ArrayList<Long> serialNumbers = new ArrayList<Long>();
        
        for(int index=0; index<loans.size(); index++){   
            serialNumbers.add(loans.get(index).getID());
        }   
            return serialNumbers;
     }
     
     /**
      * Associates a loan with a copy.
      */
     public void addLoan(Loan loan)
     {
         loans.add(loan);
     }
     
     /**
      * Cuts the connection of a loan with a copy.
      */
     public void deleteLoan(Loan loan)
     {
         loans.remove(loan);
     }
         
                   
}
